package com.hfy.admin.controller;

import com.hfy.admin.service.DraftService;
import com.hfy.model.dto.musicDraft.UploadMusicDraftDto;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import result.Result;

/**
 * @ author 韩
 * time: 2024/7/16 2:48
 */

@RestController
@RequestMapping("/draft")
@Tag(name = "草稿箱系列操作控制器" ,description = "主要对草稿箱信息做各种操作")
public class DraftController {

    @Autowired
    private DraftService draftService;


    @GetMapping("/apply_recover")
    @Operation(summary = "恢复草稿",description = "")
    @Parameters({@Parameter(name = "account",description = "账户")})
    public Result applyRecover(@RequestParam("account") Long account) {
        return draftService.applyRecover(account);
    }

    @DeleteMapping("/del_music/{id}")
    @Operation(summary = "删除草稿箱数据",description = "删除草稿箱数据通过id")
    @Parameters({@Parameter(name = "account",description = "账户")})
    public Result delDraftMusic(@PathVariable("id") Long id) {
        return draftService.delDraftMusic(id);
    }


    @PostMapping("/musicDraft")
    @Operation(summary = "上传音乐文件",description = "把前端传过来的音乐文件进行下载到OSS")
    @Parameters({@Parameter(name = "musicUrl", description = "音乐地址"),
            @Parameter(name = "account", description = "账号")}
    )
    public Result saveUploadMusicDraft(@RequestBody UploadMusicDraftDto dto) {
        return draftService.saveUploadMusicDraft(dto.getMusicUrl(), dto.getAccount());
    }
}